import 'package:flutter/material.dart';
import 'package:zhaoxiaowu_app/components/view.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/bar/bar_chart_page.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/bar/bar_chart_page2.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/bar/bar_chart_page3.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/line/line_chart_page.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/line/line_chart_page2.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/line/line_chart_page3.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/line/line_chart_page4.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/pie/pie_chart_view.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/radar/radar_chart_page.dart';
import 'package:zhaoxiaowu_app/views/accounting/chart/scatter/scatter_chart_page.dart';

class AccountingChartView extends StatefulWidget {
  @override
  _AccountingChartViewState createState() => _AccountingChartViewState();
}

class _AccountingChartViewState extends State<AccountingChartView> with SingleTickerProviderStateMixin {
  late TabController _controller;

  final _tabs = {
    "线性图": LineChartPage(),
    "线形图2": LineChartPage2(),
    "线形图3": LineChartPage3(),
    "线形图4": LineChartPage4(),
    "柱状图": BarChartPage(),
    "柱状图2": BarChartPage2(),
    "柱状图3": BarChartPage3(),
    "饼状图": PieChartPage(),
    "分散图": ScatterChartPage(),
    "雷达图": RadarChartPage(),
  };

  @override
  void initState() {
    super.initState();
    _controller = TabController(length: _tabs.keys.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(
        "图形报表",
        bottom: TabBar(
          controller: _controller,
          tabs: _tabs.keys.map((e) => Tab(text: e)).toList(),
          isScrollable: true,
          indicatorSize: TabBarIndicatorSize.label,
          indicatorColor: Colors.white,
        ),
      ),
      body: TabBarView(
        controller: _controller,
        children: _tabs.values.map((e) => e).toList(),
      ),
    );
  }
}
